package com.mv.controller;

import com.mv.entity.Movie;
import com.mv.service.MovieServiceImpl;
import com.mv.vo.MovieVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author Administrator
 */
@RequestMapping("/movie")
@Controller
public class MovieController {

    @Autowired
    MovieServiceImpl movieService;

    @RequestMapping("/searchMovieByCondition")
    @ResponseBody
    public List<Movie> searchMovieByCondition(@RequestParam(value = "typeId", defaultValue = "")Integer typeId,
                                              @RequestParam(value = "countryId", defaultValue = "")Integer countryId,
                                              @RequestParam(value = "year", defaultValue = "")Integer year,
                                              @RequestParam(value = "orderNum", defaultValue = "1")Integer orderNum){
        System.out.println("传参测试 typeId" + typeId + "   countryId" + countryId + "   year" + year + "--orderNum" + orderNum);

        return movieService.selectMovieByTypeAndTimeAndArea(typeId, countryId, year,orderNum);
    }





    @RequestMapping("/searchMovieVoById")
    @ResponseBody
    public MovieVo searchMovieByCondition(Model model){
        Integer movieId = (Integer) model.getAttribute("movieId");
        return movieService.selectMovieVoDetailById(movieId);
    }








}
